<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>国省自检--${fns:getConfig('productName')}</title>
<link rel="stylesheet" href="${ctx}/styles/gsjcss/common.css">
<script type="text/javascript">
function btnClick(){
	var url = '${ctx}/disasterPrevention/search.do?projectId=${fns:encodeParamUrl(projectId)}&menuId=${fns:encodeParamUrl(menuId)}';
	var data = {};
	if($('#btnSearch').length>0){ //有搜索按钮的情况下 获取条件进行搜索
		//将条件提取出来 
		//将条件存入data中
		//ajax请求   得到数据
		data['retrieval'] = getJson('condition');
		loadData(url,data);
	} else {
		loadData(url,data);
	}
}
//ajax执行成功之后的回调方法
function loadDataToTable(data){
	var innerList = data['innerList'];
	var attment = data['att'];
	var yearList = data['yearList'];
	var flag = data['flag'];
	var abList = data['abList'];
	var wqList = data['wqList'];
	var zhList = data['zhList'];
	loadAttachment(attment);
	
	//返回综合信息
	if($('#abwqzhfz_xmzl') != undefined){
		var result="";
		//每次搜索前清空表格
		$('#abwqzhfz_xmzl tbody').empty();
		
		for (var i = 0; i < innerList.length; i++) {
			result += '<tr><td>'+innerList[i].name+'</td><td>'+innerList[i].all+'</td><td>'+innerList[i].finished+'</td><td>'+innerList[i].rate+'%</td></tr>';
		}
		$('#abwqzhfz_xmzl tbody').append(result);
	}
	//返回各个项目类型年度情况
	if ($('#abwqzhfz-1') != undefined) {
		$('#abwqzhfz-1 tbody').empty();
	}
	if ($('#abwqzhfz-2') != undefined) {
		$('#abwqzhfz-2 tbody').empty();
	}
	if ($('#ababwqzhfz-3') != undefined) {
		$('#abwqzhfz-3 tbody').empty();
	}
	
	getProjectTable(yearList);
	
	
	if ($('#checkResult') != undefined) {
		$('#checkResult').empty();
		var result ='';
		for (var i = 0; i < innerList.length; i++) {
			result += '<tr><td>'+innerList[i].name+'</td><td>'+innerList[i].all+'</td><td>'+innerList[i].finished+'</td><td>'+innerList[i].rate+'%</td>';
			if(i == 0) {
				result += '<td class="sumTd" rowspan= '+innerList.length+'>'+data['sum']+'</td><td class="perTd" rowspan= '+innerList.length+'>'+data['percent']+'%</td>';
			}
			result += '</tr>';
		}
		var countent = '<table style="width:98%;text-align:center;margin-top:5px;" border="1"><thead><tr>'+
					   '<th>分类</th><th>总数(项)</th><th>完成数(项)</th><th>完成率</th><th>检查得分</th><th>完善度</th></tr>'+
					   '</thead><tbody>'+result+'</tbody></table>';
		$('#checkResult').append(countent);
		
	}
	
	if (flag) {
		$('#checkResult #check').empty();
		var countent = '<span style="margin-top:10px">实地检查需要实际检查数据为准:</span>';
		
		countent += '<table id="check" style="width:98%;text-align:center;margin-top:5px;" border="1"><thead>'+
					'<tr><td>序号</td><td>项目名称</td><td>里程(规模)一致(是/否)</td><td>实施内容一致(是/否)</td><td>检查得分</td></tr>'+
					'</thead><tbody> </tbody></table>';
		$('#checkResult').append(countent);
		var result = ''; 
		if (abList.length > 0) {
			for (var i = 0; i < abList.length; i++) {
				result += '<tr><td>'+parseInt(i+1)+'</td><td>'+abList[i].projectName+'</td><td></td><td></td><td></td></tr>';
			}
		}
		
		if (wqList.length > 0) {
			for (var i = 0; i < wqList.length; i++) {
				result += '<tr><td>'+parseInt(i+1+abList.length)+'</td><td>'+wqList[i].projectName+'</td><td></td><td></td><td></td></tr>';
			}
		}
		
		if (zhList.length > 0) {
			for (var i = 0; i < zhList.length; i++) {
				result += '<tr><td>'+parseInt(i+1+abList.length+wqList.length)+'</td><td>'+zhList[i].projectName+'</td><td></td><td></td><td></td></tr>';
			}
		}
		$('#checkResult #check tbody').append(result);
	}
	
}
//各个类型的项目年度情况
function getProjectTable(yearList){
	var result1 = "";
	var result2 = "";
	var result3 = "";
	for (var i = 0; i < yearList.length; i++) {
		if (yearList[i].label == 1) {
			result1 += "<tr><td class='t-font'>"+yearList[i].year+"</td><td>"+yearList[i].all+"</td><td>"+yearList[i].finished+"</td><td>"+yearList[i].spare+"</td><td>"+yearList[i].finishRate+"%</td>"+
					   "<td>"+yearList[i].total+"</td><td>"+yearList[i].subsidy+"</td><td>"+yearList[i].selfRaised+"</td><td>"+yearList[i].rate+"%</td></tr>";
		} else if ( yearList[i].label == 2 ) {
			result2 += "<tr><td class='t-font'>"+yearList[i].year+"</td><td>"+yearList[i].all+"</td><td>"+yearList[i].finished+"</td><td>"+yearList[i].spare+"</td><td>"+yearList[i].finishRate+"%</td>"+
			  		   "<td>"+yearList[i].total+"</td><td>"+yearList[i].subsidy+"</td><td>"+yearList[i].selfRaised+"</td><td>"+yearList[i].rate+"%</td></tr>";
		} else if ( yearList[i].label == 3 ) {
			result3 += "<tr><td class='t-font'>"+yearList[i].year+"</td><td>"+yearList[i].all+"</td><td>"+yearList[i].finished+"</td><td>"+yearList[i].spare+"</td><td>"+yearList[i].finishRate+"%</td>"+
			  		   "<td>"+yearList[i].total+"</td><td>"+yearList[i].subsidy+"</td><td>"+yearList[i].selfRaised+"</td><td>"+yearList[i].rate+"%</td></tr>";
		}  
	}
	$('#abwqzhfz-1 tbody').append(result1);
	$('#abwqzhfz-2 tbody').append(result2);
	$('#abwqzhfz-3 tbody').append(result3);
}


</script>
</head>
<body>
	<div id="x_top"></div>
	<tags:message content="${msg}" />
	<c:if test="${not empty checkTable.id}">
		<div style="text-align:center">
			<a href="javascript:void(0);" class="btn btn-primary" onclick="downWord('${ctx}/disasterPrevention/downWord.do?projectId=${fns:encodeParamUrl(projectId)}&menuId=${fns:encodeParamUrl(menuId)}');" id= "btnDown" role="button" ><div id="x_v"></div></a>
		</div>
	</c:if>
	<form id="checkForm" class="form-horizontal"  method="POST"  name="checkForm" action="${ctx}/disasterPrevention/save.do?left=${fns:encodeParam(left)}&parentId=${fns:encodeParam(parentId)}&projectId=${fns:encodeParam(projectId)}&menuId=${fns:encodeParam(menuId)}&leftChild=${fns:encodeParam(leftChild)}">
		<input type="hidden" name="token" value="${token}">
		<div id="show">
			<div id="showTable" class="showTable">
				<jsp:include page="/WEB-INF/views/check/common.jsp"/> 
				<div class="model">
					<div>
						<legend>三、检查条件及设置</legend>
						<div class="content-title" id="condition">
							<div style="float:left;margin-right:10px;">
								<div>
									<span>安保工程：</span>
		                            <select name="abProjectId" id="abProjectId" style='margin-right: 20px;width: 250px;'>
		                                <option value="">请选择</option>
		                                <c:forEach items="${fns:getReconstruction(projectId)}" var="itemName" varStatus="idxStatus">
		                                	<c:if test="${itemName.projectType == 1}">
			                                    <option value="${itemName.id}">${itemName.projectName}</option>
		                                	</c:if>
		                                </c:forEach>
		                       		</select>
		                       		<span>危桥改造：</span>
		                            <select name="wqProjectId" id="wqProjectId" style='margin-right: 20px;width: 250px;'>
		                                <option value="">请选择</option>
		                                <c:forEach items="${fns:getReconstruction(projectId)}" var="itemName" varStatus="idxStatus">
		                                    <c:if test="${itemName.projectType == 2}">
		                                    	<option value="${itemName.id}">${itemName.projectName}</option>
		                                    </c:if>
		                                </c:forEach>
		                       		 </select>
		                       	</div>
		                       	<div style="margin-top:20px;">
		                       		 <span>灾害防治：</span>
		                             <select name="zhProjectId" id="zhProjectId" style='margin-right: 20px;width: 250px;'>
		                                <option value="">请选择</option>
		                                <c:forEach items="${fns:getReconstruction(projectId)}" var="itemName" varStatus="idxStatus">
		                                    <c:if test="${itemName.projectType == 2}">
		                                    	<option value="${itemName.id}">${itemName.projectName}</option>
		                                    </c:if>
		                                </c:forEach>
		                       		  </select>
									<span>每类项目100%完成计划的得分<font style="color:red;">*</font>：</span>
									<input type='text' name = "yearFull" id="yearFull" value="1" class="required conInput"/>
								</div>
								<div style="margin-top:20px;">
									<span>每类项目每降低1个百分点扣分<font style="color:red;">*</font>：</span>
									<input type='text' name = "yearPart" id="yearPart" value="0.05" class="required conInput"/>
									<span>实地抽查项目与计划一致得分<font style="color:red;">*</font>：</span>
									<input type='text' name = "poitMark" id="poitMark" value="1" class="required conInput"/>
								</div>
								<div style="margin-top:20px">
									<span>实地抽查满分<font style="color:red;">*</font>：</span>
									<input type='text' name = "reserveMark" id="reserveMark" value="3" class="required conInput"/>
									<span>实地抽查单个项目与计划不一致扣分<font style="color:red;">*</font>：</span>
									<input type='text' name = "firstStepScore" id="firstStepScore" value="0.5" class="required conInput"/>
								</div>
							</div>
							<div id="x_s" style="float:right">
								<div class="x_ico"></div>
								<a href="#javascript:void(0)" onclick= "btnClick();"  id= "btnSearch" role="button" >搜索&nbsp;</a>
							</div>
						</div>
					</div>
				</div>
				<div class="model">
					<div>
						<legend>四、检索结果</legend>
						<div class="content-title">
							<div class="tabbox">
								<div class="tab">
									<c:forEach items="${childMenuList}" var="menu"  varStatus="idxStatus">
											<a href="javascript:;" ${idxStatus.index==0?"class='on'":""}>${menu.name}</a>
									</c:forEach>
							    </div>
							    <div class="content">
							    	<ul>
							    		<c:forEach items="${childMenuList}" var="menu"  varStatus="idxStatus">
							    			<li>
								    			<c:choose>
								    				<c:when test="${menu.tag eq 'abwqzhfz_xmzl'}">
								    					<table style="width:99.8%;text-align:center;margin-top:5px;" border="1" id="${menu.tag}">
											    			<thead>
											    				<th>分类</th>
												    			<th>总数(项)</th>
												    			<th>完成数(项)</th>
												    			<th>完成率</th>
												    		</thead>
										    				<tbody>
											    						
											    			</tbody>
								    					</table>
								    				</c:when>
								    				<c:when test="${menu.tag eq 'abwqzhfz_abgc'}">
								    					<table style="width:99.8%;text-align:center;margin-top:5px;" border="1" id="abwqzhfz-1">
											    			<thead>
																<th>年　　份</th>
																<th>项目数（项）</th>
																<th>完成数（项）</th>
																<th>未完成数（项）</th>
																<th>完成率（%）</th>
																<th>总投资（万元）</th>
																<th>部补助（万元）</th>
																<th>省区市自筹（万元）</th>
																<th>配套资金比例（%）</th>
												    		</thead>
										    				<tbody>
											    						
											    			</tbody>
								    					</table>
								    				</c:when>
								    				<c:when test="${menu.tag eq 'abwqzhfz_wqgz'}">
								    					<table style="width:99.8%;text-align:center;margin-top:5px;" border="1" id="abwqzhfz-2">
											    			<thead>
											    				<th>年　　份</th>
																<th>项目数（项）</th>
																<th>完成数（项）</th>
																<th>未完成数（项）</th>
																<th>完成率（%）</th>
																<th>总投资（万元）</th>
																<th>部补助（万元）</th>
																<th>省区市自筹（万元）</th>
																<th>配套资金比例（%）</th>
												    		</thead>
										    				<tbody>
											    						
											    			</tbody>
								    					</table>
								    				</c:when>
								    				<c:when test="${menu.tag eq 'abwqzhfz_zhfz'}">
								    					<table style="width:99.8%;text-align:center;margin-top:5px;" border="1" id="abwqzhfz-3">
											    			<thead>
											    				<th>年　　份</th>
																<th>项目数（项）</th>
																<th>完成数（项）</th>
																<th>未完成数（项）</th>
																<th>完成率（%）</th>
																<th>总投资（万元）</th>
																<th>部补助（万元）</th>
																<th>省区市自筹（万元）</th>
																<th>配套资金比例（%）</th>
												    		</thead>
										    				<tbody>
											    						
											    			</tbody>
								    					</table>
								    				</c:when>
								    				<c:otherwise>
									    				<table style="width:99.8%;text-align:center;margin-top:5px;" border="1" id="${menu.tag}">
											    			<thead>
											    				<th>序号</th>
												    			<th>操作</th>
												    			<th>发文单位</th>
												    			<th>上传用户</th>
												    			<th>文件名</th>
												    			<th>发文日期</th>
												    			<th>上传日期</th>
												    			<th>文件大小</th>
												    			<th>文件类型</th>
												    		</thead>
										    				<tbody>
											    						
											    			</tbody>
									    				</table>
								    				</c:otherwise>
								    			</c:choose>
							    			</li>
							    		</c:forEach>
							        </ul>
							    </div>
							</div>
						</div>
					</div>
				</div>
				<div class="model">
					<div>
						<legend>五、检查评分</legend>
						<div class="content-title" id="checkResult">
						
						</div>
					</div>
				</div>
				<div class="model">
					<div class="content-btn">
						<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存" />
						&nbsp;&nbsp;&nbsp;&nbsp;
						<input id="btnCancel" class="btn" type="button" value="返 回" onclick="toBack()" />
					</div>
				</div>
			</div>
		</div>
	</form>
	<script src="${ctxStatic}/js/check/checkCommon.js" type="text/javascript"></script>
</body>
</html>